<div id="Content">
<form action='' method='post'>
	<p><label for="email">UserName: </label><input type="text" name="UserName" placeholder="User name...." /></p>
	<p><label for="pass">Password: </label><input type="password" name="PassWord" placeholder="Password..." /></p>
	<p><input type="submit" name="DangNhap" value="LogIn" class="btnLogin" /></p>
</form>

	<?php
	
	if(isset($_POST['DangNhap']))
	{
		$u=$p="";
		if($_POST['UserName'] == NULL)
		{
			echo "Please enter your username<br />";
		}
		else
		{
			$u=$_POST['UserName'];
		}
		if($_POST['PassWord'] == NULL)
		{
			echo "Please enter your password<br />";
		}
		else
		{
			$p=$_POST['PassWord'];
		}
		if($u && $p)
		{
			$con=mysql_connect("localhost","root","") or die("can't connect this database");
			mysql_select_db("qlanh",$con);
			$sql="select * from member where IDTHANHVIEN='".$u."' and PASS='".$p."'";
			$query=mysql_query($sql);
			if(mysql_num_rows($query) == 0)
			{
				echo "Username or password is not correct, please try again";
			}
			 else
			{
				$row=mysql_fetch_array($query);
				session_start();
				$_SESSION['MATHANHVIEN'] = $row['ROLE'];
				$_SESSION['ROLE'] = $row['ROLE'];

				if(isset($_SESSION['MATHANHVIEN']) && $_SESSION['ROLE'] == 1)
				{
					// tại đây thực thi các hoạt động khi đăng nhập thành công.
					header("location: admin.php");
				}
				else
				{
				 header("location: member.php");
				 exit();
				}
			}
		}
	}
	?>
</div>